// SetAtwleValueDlg.cpp : implementation file
//

#include "stdafx.h"
#include "Problem2-Schedule.h"
#include "SetAtwleValueDlg.h"


// CSetAtwleValueDlg dialog

IMPLEMENT_DYNAMIC(CSetAtwleValueDlg, CDialog)

CSetAtwleValueDlg::CSetAtwleValueDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CSetAtwleValueDlg::IDD, pParent)
	, m_nodeCount(24)
	, m_nodeIndex(0)
{
}

CSetAtwleValueDlg::~CSetAtwleValueDlg()
{
}

void CSetAtwleValueDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
}


BEGIN_MESSAGE_MAP(CSetAtwleValueDlg, CDialog)
	ON_BN_CLICKED(IDOK, &CSetAtwleValueDlg::OnBnClickedOk)
END_MESSAGE_MAP()


// CSetAtwleValueDlg message handlers

void CSetAtwleValueDlg::OnBnClickedOk()
{
	// set values
	{
		m_nodeIndex = ( (CComboBox*)this->GetDlgItem( IDC_COMBO_NODE ) )->GetCurSel();

		m_atwleNode.es = ( (CComboBox*)this->GetDlgItem( IDC_COMBO_ES ) )->GetCurSel();

		m_atwleNode.tag = ( (CComboBox*)this->GetDlgItem( IDC_COMBO_TAG ) )->GetCurSel();

		m_atwleNode.marked = (( (CComboBox*)this->GetDlgItem( IDC_COMBO_MARKED ) )->GetCurSel() == 1 );

		m_atwleNode.is_leader = (( (CComboBox*)this->GetDlgItem( IDC_COMBO_IS_LEADER ) )->GetCurSel() == 1 );

		m_atwleNode.finished = (( (CComboBox*)this->GetDlgItem( IDC_COMBO_FINISHED ) )->GetCurSel() == 1 );
	}

	OnOK();
}

BOOL CSetAtwleValueDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	// TODO:  Add extra initialization here
	{
		for (int i=0; i<m_nodeCount; i++)
		{
			CString str;
			str.Format("%c", 'A'+i);
			( (CComboBox*)this->GetDlgItem( IDC_COMBO_NODE ) )->AddString( str );
		}

		( (CComboBox*)this->GetDlgItem( IDC_COMBO_ES ) )->AddString( "0" );
		( (CComboBox*)this->GetDlgItem( IDC_COMBO_ES ) )->AddString( "1" );
		( (CComboBox*)this->GetDlgItem( IDC_COMBO_ES ) )->AddString( "2" );

		( (CComboBox*)this->GetDlgItem( IDC_COMBO_MARKED ) )->AddString( "false" );
		( (CComboBox*)this->GetDlgItem( IDC_COMBO_MARKED ) )->AddString( "true" );

		( (CComboBox*)this->GetDlgItem( IDC_COMBO_TAG ) )->AddString( "0" );
		( (CComboBox*)this->GetDlgItem( IDC_COMBO_TAG ) )->AddString( "1" );
		( (CComboBox*)this->GetDlgItem( IDC_COMBO_TAG ) )->AddString( "2" );
		( (CComboBox*)this->GetDlgItem( IDC_COMBO_TAG ) )->AddString( "3" );
		( (CComboBox*)this->GetDlgItem( IDC_COMBO_TAG ) )->AddString( "4" );

		( (CComboBox*)this->GetDlgItem( IDC_COMBO_IS_LEADER ) )->AddString( "false" );
		( (CComboBox*)this->GetDlgItem( IDC_COMBO_IS_LEADER ) )->AddString( "true" );

		( (CComboBox*)this->GetDlgItem( IDC_COMBO_FINISHED ) )->AddString( "false" );
		( (CComboBox*)this->GetDlgItem( IDC_COMBO_FINISHED ) )->AddString( "true" );

	}

	// initial values
	{
		( (CComboBox*)this->GetDlgItem( IDC_COMBO_NODE ) )->SetCurSel(m_nodeIndex);

		( (CComboBox*)this->GetDlgItem( IDC_COMBO_ES ) )->SetCurSel(m_atwleNode.es);
		
		( (CComboBox*)this->GetDlgItem( IDC_COMBO_TAG ) )->SetCurSel(m_atwleNode.tag);

		( (CComboBox*)this->GetDlgItem( IDC_COMBO_MARKED ) )->SelectString( 0, m_atwleNode.marked ? "true" : "false");

		( (CComboBox*)this->GetDlgItem( IDC_COMBO_IS_LEADER ) )->SelectString( 0, m_atwleNode.is_leader ? "true" : "false");

		( (CComboBox*)this->GetDlgItem( IDC_COMBO_FINISHED ) )->SelectString( 0, m_atwleNode.finished ? "true" : "false");
	}

	return TRUE;  // return TRUE unless you set the focus to a control
	// EXCEPTION: OCX Property Pages should return FALSE
}
